package com.itheima.controller;

import com.itheima.domain.UmsResourceCategory;
import com.itheima.manager.UmsResourceCategoryManager;
import com.itheima.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZhuHongKai
 * @version 1.0
 * @ClassName UmsResourceController
 * @date 2022/11/13 1:44
 */
@RestController
public class UmsResourceCategoryController {

    @Autowired
    UmsResourceCategoryManager umsResourceCategoryManager;

    /**
     * 查询所有后台资源分类
     * @return
     */
    @RequestMapping(value = "/resourceCategory/listAll",method = RequestMethod.GET)
    public R listAll(){
        return umsResourceCategoryManager.listAll();
    }

    /**
     * 修改后台资源分类
     * @param id
     * @return
     */
    @PostMapping("/resourceCategory/update/{id}")
    public R resourceCategoryUpdate(@PathVariable Long id,@RequestBody UmsResourceCategory umsResourceCategory){
        return umsResourceCategoryManager.resourceCategoryUpdate(id,umsResourceCategory);
    }

    /**
     * 根据ID删除后台资源
     * @param id
     * @return
     */
    @PostMapping("/resourceCategory/delete/{id}")
    public R delete(@PathVariable Long id){
        return umsResourceCategoryManager.delete(id);
    }

    /**
     * 添加后台资源分类
     * @param umsResourceCategory
     * @return
     */
    @PostMapping("/resourceCategory/create")
    public R save(@RequestBody UmsResourceCategory umsResourceCategory){
        return umsResourceCategoryManager.save(umsResourceCategory);
    }

}
